package com.zc.demo.service;


import com.zc.demo.mapper.BookMapper;
import com.zc.demo.model.BookInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {
    @Autowired
    private BookMapper bookMapper;

    public void addBook(BookInfo bookInfo){
        bookMapper.insertBook(bookInfo);
    }

    public List<BookInfo> getListBookInfo(){
        List<BookInfo> books = bookMapper.queryAll();
        for (BookInfo book:books){
            if (book.getStatus()==0){
                book.setStatusCN("⽆效");
            }else if (book.getStatus()==1){
                book.setStatusCN("可借阅");
            }else {
                book.setStatusCN("不可借阅");
            }
        }
        return books;
    }
}
